var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function (t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        i(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }),
    a = this && this.__decorate ||
        function (t, e, o, i) {
            var n, a = arguments.length,
                r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
            else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
            return a > 3 && r && Object.defineProperty(e, o, r),
                r
        };
Object.defineProperty(o, "__esModule", {
    value: !0
}),
    o.http_get_ex = o.WXChannel = void 0;
var r, s = t("GlobalUserData"),
    l = t("AdUnitManager"),
    c = t("ChannelTool"),
    d = t("HttpUtil"),
    h = t("HWSdk"),
    p = t("NativeManager"),
    u = t("Util"),
    f = t("AssetsManager"),
    m = t("GameResPkg"),
    _ = t("ResManager"),
    y = t("SceneManager"),
    g = t("StorageManager"),
    v = t("BaseStorage"),
    C = t("TermsServiceView"); (function (t) {
        t[t.ZUZHUANG = 0] = "ZUZHUANG",
            t[t.MIAOXING = 1] = "MIAOXING",
            t[t.CHAOJI = 2] = "CHAOJI",
            t[t.BIAOCHE = 3] = "BIAOCHE"
    })(r = o.WXChannel || (o.WXChannel = {}));
var b = cc._decorator,
    w = b.ccclass,
    S = b.property,
    I = function (t) {
        function e() {
            var e = null !== t && t.apply(this, arguments) || this;
            return e.wx_channel = r.ZUZHUANG,
                e.progressLoad = null,
                e.loading = null,
                e.spr_logo = null,
                e.frame_logo = null,
                e.spr_bg = null,
                e.frame_bg = null,
                e.wx_logo_list = [],
                e.node_splash = null,
                e.totalTime = 3,
                e.curTime = 0,
                e.nCurLoad = 0,
                e.curPro = {
                    a: 0
                },
                e.hallScene = null,
                e.isLoadSucc = !1,
                e.loading10 = !1,
                e.loading50 = !1,
                e.loading80 = !1,
                e.loading100 = !1,
                e.isComplete = !1,
                e.isTime = !1,
                e
        }
        return n(e, t),
            e.prototype.onLoad = function () {
                this.progressLoad.progress = 0,
                    g.StorageManager.refreshDailyTaskStorage()
            },
            e.prototype.start = function () {
                setTimeout(() => {
                    this.isTime = !0;
                    if (this.isComplete) this.enterGame();
                }, 2000);
                var t = this;
                if (s.default.wx_channel = this.wx_channel, s.default.initLoginTimeData(), 0 == s.default.nFirstDate) this._strOldUser = "1";
                else {
                    var e = (new Date().getTime() - s.default.nFirstDate) / 36e5;
                    this._strOldUser = e >= 24 ? "2" : "1"
                }
                u.Util.initChannel(),
                    // s.default.wx_channel == r.BIAOCHE ? (this.spr_logo.spriteFrame = this.frame_logo, this.spr_bg.spriteFrame = this.frame_bg, d.HttpUtil.GET("https://darknight.games/api/wx/wx_game/ad_unit", {
                    //     appid: "wxf0a688d652a4b7d2"
                    // },
                    //     function (t, e) {
                    //         s.default.biaocheAdUnitList = JSON.parse(e),
                    //             console.log("请求结果：" + JSON.stringify(s.default.biaocheAdUnitList)),
                    //             l.default.getIntance().initAdUnit()
                    //     })) : (l.default.getIntance().initAdUnit(), this.spr_logo.spriteFrame = this.wx_logo_list[Number(this.wx_channel)]),
                    u.Util.wxReportUseBehavior("loading", "enter", 1, this._strOldUser),
                    this.node_splash.active = !0,
                    this.channelInfo2(this.loadAssets.bind(this));
                // this.loadAssets();
                // u.Util.isNative() || u.Util.is_qg ? this.scheduleOnce(function () {
                //     u.Util.isNative() ? p.default.instance.init(function () {
                //         t.loadHttpDataByCallBack(t.loadAssets.bind(t))
                //     }) : t.loadHttpDataByCallBack(t.loadAssets.bind(t))
                // },
                //     2) : this.loadHttpDataByCallBack(this.loadAssets.bind(this))
            },
            e.prototype.update = function () {
                if (this.progressLoad.progress = this.curPro.a / f.assetBundle.length, this.loading.string = "loading:" + Math.floor(100 * this.progressLoad.progress) + "%", this.progressLoad.progress >= .1 && !this.loading10 && (this.loading10 = !0, console.log("加载10"), u.Util.wxReportUseBehavior("loading", "load10", 1, this._strOldUser)), this.progressLoad.progress >= .5 && !this.loading50 && (this.loading50 = !0, console.log("加载50"), u.Util.wxReportUseBehavior("loading", "load50", 1, this._strOldUser)), this.progressLoad.progress >= .9 && !this.loading80 && (this.loading80 = !0, console.log("加载80"), u.Util.wxReportUseBehavior("loading", "load80", 1, this._strOldUser)), this.progressLoad.progress >= 1 && !this.loading100 && (this.loading100 = !0, console.log("加载100"), u.Util.wxReportUseBehavior("loading", "load100", 1, this._strOldUser)), this.nCurLoad >= f.assetBundle.length && !this.isComplete) {
                    this.isComplete = !0,
                        console.log("加载完成");
                    // var t = cc.sys.localStorage.getItem("user_server_status_data");
                    // !u.Util.is_qg() && !u.Util.isNative() || t ? this.enterGame() : this.showServerView()
                    if (this.isTime) this.enterGame();
                }
            },
            e.prototype.showServerView = function () {
                var t = this;
                cc.resources.load("server/termsService", cc.Prefab,
                    function (e, o) {
                        var i = cc.instantiate(o);
                        i.getComponent(C.default).CallBack = t.enterGame.bind(t),
                            i.parent = t.node
                    })
            },
            e.prototype.enterGame = function () {
                u.Util.is_HW() ? h.default.Ins.gameLogin(function () {
                    _.default.getInstance().preloadResPkg(m.default, null,
                        function () {
                            y.SceneManager.Instance.runScene(y.SceneName.hall)
                        })
                }) : _.default.getInstance().preloadResPkg(m.default, null,
                    function () {
                        y.SceneManager.Instance.runScene(y.SceneName.hall)
                    })
            },
            e.prototype.loadAssets = function () {
                for (var t = this,
                    e = function (e) {
                        cc.assetManager.loadBundle(f.BundleName[f.assetBundle[e].name],
                            function (o, i) {
                                if (o) return cc.error(o);
                                f.assetBundle[e].bundle = i,
                                    cc.log("load resources subpackage (" + f.BundleName[f.assetBundle[e].name] + ") successfully."),
                                    t.refreshProBar()
                            })
                    },
                    o = 0; o < f.assetBundle.length; o++) e(o)
            },
            e.prototype.refreshProBar = function () {
                this.nCurLoad++,
                    cc.tween(this.curPro).to(.5, {
                        a: this.nCurLoad
                    }).start(),
                    console.log("nCurLoad:" + this.nCurLoad)
            },
            e.prototype.loadScene = function () {
                v.BaseStorage.setString("CoinAwardShow", "show"),
                    cc.director.runScene(this.hallScene)
            },
            e.prototype.loadHttpDataByCallBack = function (t) {
                var e = this,
                    o = "local";
                // if (c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.WE_CHAT) switch (s.default.wx_channel) {
                //     case r.ZUZHUANG:
                //         o = "https://xiazai.qi-guo.cn/Cats/config_wx.json";
                //         break;
                //     case r.CHAOJI:
                //         o = "https://xiazai.qi-guo.cn/Cats/config_wx_cwdzc.json";
                //         break;
                //     case r.BIAOCHE:
                //         o = "https://xiazai.qi-guo.cn/Cats/config_wx_operation.json";
                // }
                // c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.OPPO && (o = "https://xiazai.qi-guo.cn/Cats/config_oppo.json"),
                //     c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.VIVO && (o = "https://xiazai.qi-guo.cn/Cats/config_vivo.json"),
                //     c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.BYTE && (o = "https://xiazai.qi-guo.cn/Cats/config_tt.json"),
                //     u.Util.is_233() && (o = "https://xiazai.qi-guo.cn/Cats/config_233.json"),

                o == "local" ? cc.resources.load(o, cc.JsonAsset, function (o, i) {
                    if (o) return console.error(o),
                        void e.channelInfo({},
                            t);
                    var n = i.json;
                    e.channelInfo(n, t)
                }) : cc.assetManager.loadRemote(o,
                    function (o, i) {
                        if (o) return console.error(o),
                            void e.channelInfo({},
                                t);
                        var n = i.json;
                        e.channelInfo(n, t)
                    })
            },
            e.prototype.channelInfo = function (t, e) {
                console.log("loadHttpDataByCallBack succ", t);
                var o = t.version || "";
                s.default.Version == o || "" === o ? s.default.bAuditMode = !0 : s.default.bAuditMode = !1,
                    s.default.oneMinuteInterval = t.oneMinuteInterval || !1,
                    s.default.superCarPro = t.superCarPro || .5,
                    s.default.newcomer = t.newcomer || .5,
                    s.default.freePopup = t.freePopup || !0,
                    s.default.coinPopup = t.coinPopup || !0,
                    s.default.signPopup = t.signPopup || !0,
                    s.default.operationData.sceneIds = t.block_scene_touchBanner || [],
                    s.default.operationData.bannerTouchSW = t.bannerTouchSW || !1,
                    s.default.bannerOnRight = t.bannerOnRight || !1,
                    s.default.repeatClick = t.repeatClick || !1,
                    s.default.fullScreenVideoInterval = t.fullScreenVideoInterval || {
                        X: !1,
                        Y: 60
                    },
                    s.default.insertAD = t.insertAD || {
                        X: !1,
                        Y: 60
                    },
                    console.log("233广告配置全屏：" + JSON.stringify(s.default.fullScreenVideoInterval)),
                    console.log("233广告配置插屏：" + JSON.stringify(s.default.insertAD)),
                    s.default.bShowAd = t.Ad || !1,
                    s.default.bShowInsertAd = t.insertAd || !1,
                    s.default.bShowBannerAd = t.bannerAd || !1,
                    s.default.bShowNativeAd = t.nativeAd || !1,
                    s.default.inAdPro = t.probability || 0,
                    s.default.strShareType = t.shareType || "",
                    s.default.block_citys = t.block_citys || [],
                    s.default.block_scene = t.block_scene || [],
                    s.default.block_citys_mistakeBanner = t.block_citys_mistakeBanner || [],
                    s.default.block_scene_mistakeBannner = t.block_scene_mistakeBannner || [],
                    s.default.isShowMistakeBanner = t.isShowMistakeBanner || !1,
                    s.default.isRefreshMatchBanner = t.isRefreshMatchBanner || !1,
                    s.default.helpProp = t.helpProp || .5,
                    s.default.upgradeVideoList = t.upgradeVideoList || [],
                    s.default.btnShowAdEnabled = t.btnShowAdEnabled || !1,
                    s.default.mistakeNativeBanneProbability = t.mistakeNativeBanneProbability || 0,
                    s.default.clickBoxNativeList = t.clickBoxNativeList || 0,
                    s.default.videoItemProbability = t.videoItemProbability || 0,
                    s.default.btnGetDelayTime = t.btnGetDelayTime || 0,
                    s.default.nativeInsertAdEnabled = t.nativeInsertAdEnabled || !1,
                    s.default.installShortCutList = t.installShortCutList || [],
                    s.default.hallNativeInsertAdEnabled = t.hallNativeInsertAdEnabled || !1,
                    s.default.nativeMatchBannerList = t.nativeMatchBannerList || [],
                    s.default.nativeMistakeBannerList = t.nativeMistakeBannerList || [],
                    s.default.matchViewInsertAdList = t.matchViewInsertAdList || [],
                    s.default.showPanelBackHome = t.showPanelBackHome || [],
                    s.default.Version == o ? s.default.shareInfo = t.share_msg : "share" == s.default.strShareType ? s.default.shareInfo = t.share_msg : s.default.shareInfo = t.fake_share_msg,
                    s.default.arrShowSpeed = t.gift_rush || [],
                    s.default.init(),
                    // u.Util.LoadSwitchInfo(),
                    e()
            },
            e.prototype.channelInfo2 = function (e) {
                s.default.init(),
                    e()
            },
            a([S({
                type: cc.Enum(r)
            })], e.prototype, "wx_channel", void 0),
            a([S(cc.ProgressBar)], e.prototype, "progressLoad", void 0),
            a([S(cc.Label)], e.prototype, "loading", void 0),
            a([S(cc.Sprite)], e.prototype, "spr_logo", void 0),
            a([S(cc.SpriteFrame)], e.prototype, "frame_logo", void 0),
            a([S(cc.Sprite)], e.prototype, "spr_bg", void 0),
            a([S(cc.SpriteFrame)], e.prototype, "frame_bg", void 0),
            a([S(cc.SpriteFrame)], e.prototype, "wx_logo_list", void 0),
            a([S(cc.Node)], e.prototype, "node_splash", void 0),
            a([w], e)
    }(cc.Component);
o.default = I,
    o.http_get_ex = function () {
        throw new Error("Function not implemented.")
    }